package com.ms.game.offlineSpin.async;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.ms.game.offlineSpin.OfflineSpinStopCondition;
import com.xpec.c4.db.dao.PlayerDAO;
import com.xpec.c4.game.utility.GUID;
import com.xpec.c4.service.module.task.TaskAsyncCommand;

/**
 * 因為某些中斷原因而修改離線SPIN結果
 * @author 16040
 *
 */
public class SaveOfflineSpinStopResultAsync extends TaskAsyncCommand{

	private static final Log log = LogFactory.getLog(SaveOfflineSpinStopResultAsync.class);
	
	/**
	 * 目標玩家
	 */
	private GUID playerGUID;
	
	/**
	 * 停止原因
	 */
	private OfflineSpinStopCondition condition;
	
	@Override
	public void asyncExecute() throws Exception {
		if(playerGUID == null || condition == null)
			return;
		
		if(log.isInfoEnabled()){
			log.info("SaveOfflineSpinStopResultAsync update stop condition:"+condition.name()+", playerGUID:"+playerGUID.toString());
		}
		
		PlayerDAO.updatePlayerOfflineSpinStopResult(playerGUID, condition.getStringTableID());
	}

	@Override
	public void execute() throws Exception {
		
	}

	public void setPlayerGUID(GUID playerGUID) {
		this.playerGUID = playerGUID;
	}

	public void setCondition(OfflineSpinStopCondition condition) {
		this.condition = condition;
	}

}
